<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>用户注册 | 航空管理系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-blue: #2980b9;
            --secondary-purple: #8e44ad;
        }

        body {
            background: url('img/login_background.png') no-repeat center center fixed;
            background-size: cover;
            min-height: 100vh;
            padding-top: 80px;
        }

        /* 半透明导航栏 */
        .main-navbar {
            background: rgba(255, 255, 255, 0.85) !important;
            backdrop-filter: blur(12px);
            box-shadow: 0 2px 15px rgba(0,0,0,0.1);
            height: 80px;
        }

        /* 更透明的导航栏 */
        .main-navbar {
            background: rgba(255, 255, 255, 0.75) !important; /* 透明度从0.85改为0.75 */
            backdrop-filter: blur(12px); /* 增加模糊度 */
            box-shadow: 0 2px 15px rgba(0,0,0,0.1);
            border-bottom: 1px solid rgba(255,255,255,0.2); /* 更明显的底部边框 */
        }

        /* 导航栏内容布局 */
        .brand-wrapper {
            display: flex;
            align-items: center;
            gap: 20px;
            margin-left: 2rem;
        }
        .brand-logo {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            object-fit: cover;
            border: 2px solid var(--primary-blue);
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        .brand-text {
            font-size: 1.8rem;
            font-weight: 600;
            color: var(--primary-blue);
            text-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        /* 注册卡片 */
        .register-container {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: calc(100vh - 160px);
        }
        .register-card {
            background: rgba(255, 255, 255, 0.92);
            backdrop-filter: blur(8px);
            border-radius: 20px;
            box-shadow: 0 15px 30px rgba(0,0,0,0.18);
            width: 100%;
            max-width: 600px;
            padding: 2.5rem;
            border: 1px solid rgba(255,255,255,0.4);
            transform: translateY(-5px);
            transition: all 0.3s ease;
        }
        .register-card:hover {
            transform: translateY(-8px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.25);
        }

        /* 表单元素 */
        .form-control {
            border-radius: 30px;
            padding: 1rem 1.8rem;
            border: 2px solid rgba(41, 128, 185, 0.15);
            transition: all 0.3s ease;
        }
        .form-control:focus {
            border-color: var(--primary-blue);
            box-shadow: 0 0 0 4px rgba(41, 128, 185, 0.2);
        }

        /* 头像上传 */
        .avatar-upload {
            position: relative;
            width: 160px;
            margin: 0 auto 2rem;
            cursor: pointer;
        }
        .avatar-preview {
            width: 160px;
            height: 160px;
            border-radius: 50%;
            object-fit: cover;
            border: 3px solid var(--primary-blue);
            box-shadow: 0 8px 20px rgba(0,0,0,0.12);
            transition: all 0.3s ease;
        }
        .avatar-upload:hover .avatar-preview {
            transform: scale(1.05);
            box-shadow: 0 12px 25px rgba(0,0,0,0.15);
        }
        .upload-icon {
            position: absolute;
            bottom: 10px;
            right: 10px;
            background: var(--primary-blue);
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        }

        /* 注册按钮 */
        .register-btn {
            background: linear-gradient(135deg, var(--primary-blue), var(--secondary-purple));
            border: none;
            padding: 1rem 2rem;
            font-size: 1.1rem;
            letter-spacing: 1px;
            border-radius: 30px;
            transition: all 0.3s ease;
        }
        .register-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(41, 128, 185, 0.3);
        }

         /* 身份证输入样式 */
         .id-card-group {
            position: relative;
        }
        .id-card-icon {
            position: absolute;
            right: 20px;
            top: 50%;
            transform: translateY(-50%);
            color: #666;
            pointer-events: none;
        }
    </style>
</head>
<body>

    <nav class="main-navbar navbar navbar-expand-lg fixed-top">
        <div class="container-fluid px-4">
            <div class="brand-wrapper">
                <img src="img/logo.jpg" alt="航空管理系统" class="brand-logo">
                <span class="brand-text">通辽航空管理系统</span>
            </div>
            <div class="d-flex align-items-center">
                <a href="login.jsp" class="btn btn-outline-primary">已有账号？立即登录</a>
            </div>
        </div>
    </nav>

    <!-- 注册主体 -->
    <div class="register-container">
        <div class="register-card">
            <h2 class="text-center mb-4 fw-bold text-primary">欢迎注册</h2>
            
            <form id="registerForm" action="UserRegisterServlet" method="post" enctype="multipart/form-data">
                <!-- 头像上传 -->
                <div class="avatar-upload">
                    <input type="file" id="avatarInput" name="avatar" accept="image/*" hidden required>
                    <img src="images/default-avatar.png" class="avatar-preview" id="avatarPreview">
                    <div class="upload-icon">
                        <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-camera" viewBox="0 0 16 16">
                            <path d="M15 12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h1.172a3 3 0 0 0 2.12-.879l.83-.828A1 1 0 0 1 6.827 3h2.344a1 1 0 0 1 .707.293l.828.828A3 3 0 0 0 12.828 5H14a1 1 0 0 1 1 1zM2 4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-1.172a2 2 0 0 1-1.414-.586l-.828-.828A2 2 0 0 0 9.172 2H6.828a2 2 0 0 0-1.414.586l-.828.828A2 2 0 0 1 3.172 4z"/>
                            <path d="M8 11a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5m0 1a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7M3 6.5a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0"/>
                        </svg>
                    </div>
                </div>

                <!-- 注册表单 -->
                <div class="mb-4">
                    <input type="text" 
                           class="form-control" 
                           name="userName" 
                           placeholder="👤 真实姓名"
                           pattern="[\u4e00-\u9fa5]{2,10}"
                           required>
                </div>

                <div class="mb-4">
                    <input type="tel" 
                           class="form-control" 
                           name="phone" 
                           placeholder="📱 手机号码"
                           pattern="1[3-9]\d{9}"
                           required>
                </div>

                <div class="mb-4">
                    <input type="password" 
                           class="form-control" 
                           name="password" 
                           placeholder="🔒 设置密码（至少6位）"
                           minlength="6"
                           required>
                </div>

                <!-- 新增身份证号码 -->
                <div class="mb-4 id-card-group">
                    <input type="text" 
                           class="form-control" 
                           name="idCard" 
                           placeholder="🆔 身份证号码"
                           pattern="\d{17}[\dXx]"
                           required>
                    <span class="id-card-icon">ⓘ</span>
                </div>

                <button type="submit" class="btn register-btn w-100 text-white">提交注册申请</button>
            </form>
        </div>
    </div>

    <script>
        // 头像预览功能
        const avatarInput = document.getElementById('avatarInput');
        const avatarPreview = document.getElementById('avatarPreview');

        avatarInput.addEventListener('change', function(e) {
            const file = e.target.files[0];
            if (file && file.type.startsWith('image/')) {
                const reader = new FileReader();
                reader.onload = function(e) {
                    avatarPreview.src = e.target.result;
                    avatarPreview.style.transform = 'scale(1.05)';
                    setTimeout(() => {
                        avatarPreview.style.transform = 'scale(1)';
                    }, 300);
                }
                reader.readAsDataURL(file);
            }
        });

        // 点击任意位置触发文件选择
        avatarPreview.addEventListener('click', () => {
            avatarInput.click();
        });
    </script>

<script>
    // 身份证输入提示
    document.querySelector('input[name="idCard"]').addEventListener('focus', function() {
        Swal.fire({
            title: '身份证格式要求',
            text: '请输入18位有效身份证号码，最后一位可以是数字或X',
            icon: 'info',
            confirmButtonText: '明白了'
        });
    });
</script>
</body>
</html>